package nl.ceasaro.jeslee.core.stock.dao.impl;

import nl.ceasaro.jeslee.core.stock.dao.DressDAO;
import nl.ceasaro.jeslee.core.model.clothes.Dress;
import nl.ceasaro.jeslee.core.dao.impl.AbstractHibernateDAO;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Component
public class DressHibernatedDAO extends AbstractHibernateDAO<Dress, Long> implements DressDAO
{

   @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
   public Dress getByName(String name)
   {
      Criteria criteria = createCriteria();
      criteria.add(Restrictions.eq("name", name));
      return (Dress) criteria.uniqueResult();
   }

}